/**
 * Copyright (c) 2011 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.uac.session;

import java.util.List;

import com.eelpo.cmmp.uac.dao.vo.Entity;
import com.eelpo.cmmp.uac.dao.vo.Permission;
import com.eelpo.cmmp.uac.dao.vo.User;
import com.eelpo.common.util.BlankUtils;

import org.apache.wicket.Request;

/**
 * <pre>
 * 登录用户Session对象
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public class LoginSession extends UACSession {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 2846840881881195677L;

	/**
	 * 登陆用户
	 */
	private User user;

	/**
	 * 构造函数
	 * 
	 * @param request
	 *            请求对象
	 */
	public LoginSession(Request request) {
		super(request);
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see com.eelpo.cmmp.core.wicket.session.CMMPSession#getUserId()
	 */
	@Override
	public String getUserId() {
		return isAuthorized() ? getUser().getId() : null;
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see com.eelpo.cmmp.uac.session.UACSession#getUser()
	 */
	@Override
	public User getUser() {
		return user;
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see com.eelpo.cmmp.uac.session.UACSession#setUser(com.eelpo.cmmp.uac.dao.vo.User)
	 */
	@Override
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see com.eelpo.cmmp.uac.session.UACSession#getMenus()
	 */
	@Override
	public List<Entity> getMenus() {
		return null;
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see com.eelpo.cmmp.uac.session.UACSession#getPermissions()
	 */
	@Override
	public List<Permission> getPermissions() {
		return null;
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see com.eelpo.cmmp.uac.session.UACSession#setPermissions(java.util.Collection)
	 */
	@Override
	public void setPermissions(List<Permission> permissions) {
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see com.eelpo.cmmp.core.wicket.session.CMMPSession#isAuthorized()
	 */
	@Override
	public final boolean isAuthorized() {
		return !BlankUtils.isBlank(getUser());
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see com.eelpo.cmmp.core.wicket.session.CMMPSession#checkPermission(java.lang.String,
	 *      java.lang.String)
	 */
	@Override
	public boolean checkPermission(String entityCode, String actionCode) {
		return false;
	}

	/**
	 * (non-Javadoc)
	 * 
	 * @see com.eelpo.cmmp.core.wicket.session.CMMPSession#checkAuthority(java.lang.String,
	 *      java.lang.String)
	 */
	@Override
	public boolean checkAuthority(String entityCode, String authorityCode) {
		return false;
	}

}
